import { defineComponent, ref, onMounted } from 'vue';
import { IndustryRankMap } from '@config/map';
import { CompListAPI } from '@/service/api/InsightAPI';
import IndustryMap from './IndustryMap';
import CompList from './CompList';
import './style.scss';

export default defineComponent({
  name: 'Insight',
  props: {
    msg: String,
  },
  setup() {
    const CompListData = ref([]);
    // 区域、战新类型 及 对应code
    const IndustryRegion = sessionStorage.getItem('IndustryRegion') || '工业园区';
    const IndustryName = sessionStorage.getItem('IndustryName') || '生物产业';
    const seic_lv1_code = IndustryRankMap?.find((i) => i.name === IndustryName)?.seic_lv1_code;

    onMounted(async () => {
      //   获取数据
      CompListData.value = await CompListAPI({
        filter: {
          region: {
            province: '江苏省', //省份
            city: '苏州市', //市
            district: IndustryRegion, //区
          },
          seic_lv1_code, //筛选 这个是一级战新的code值，默认选生物医药，生物医药code 是 4
        },
        order: {
          order_field: 'registered_capital',
          order_type: 'desc',
        },
        start: 1, //分页，开始页
        rows: 6, //分页，每页显示多少数据
      });
    });

    return { IndustryRegion, CompListData, seic_lv1_code };
  },
  render() {
    return (
      <div id="Insight">
        <main>
          <IndustryMap
            city={this.IndustryRegion}
            data={this.CompListData}
            seicLv1Code={this.seic_lv1_code}
          ></IndustryMap>

          <CompList data={this.CompListData}></CompList>
        </main>

        <footer></footer>
      </div>
    );
  },
});
